package org.fangzz.cameramgr.cameramonitor.rest;


import org.fangzz.cameramgr.cameramonitor.dto.StoreQueryParameter;
import org.fangzz.cameramgr.cameramonitor.dto.StoreSummary;
import org.fangzz.cameramgr.cameramonitor.model.Store;
import org.fangzz.cameramgr.cameramonitor.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.stream.Collectors;

/**
 * created by XxChen 2018/6/22
 */

@RestController
public class StoreRestController {

    @Autowired
    private StoreService storeService;

    /**
     * 查询区域内所有门店并分页
     * @param parameter
     * @return
     */

    @GetMapping("/api/store")
    public Page<StoreSummary> findByAreaCode(StoreQueryParameter parameter){
        Page<Store> storePage = storeService.findByAreaCode(parameter);
        return StoreSummary.convert(storePage);
    }



}
